
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>

#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>

#define xml_GetProfiles_respon "GetProfiles_respon.xml"

/**
 * print_element_names:
 * @a_node: the initial xml node to consider.
 *
 * Prints the names of the all the xml elements
 * that are siblings or children of a given xml node.
 */
static void
print_element_names(xmlNode *a_node)
{
    xmlNode *cur_node = NULL;

    for (cur_node = a_node; cur_node; cur_node = cur_node->next)
    {
        if (cur_node->type == XML_ELEMENT_NODE)
        {
            printf("node type: Element, name: %s\n", cur_node->name);
        }

        print_element_names(cur_node->children);
    }
}

int main(int argc, char **argv)
{

    xmlDoc *doc = NULL;
    xmlNode *root_element = NULL;

    xmlNode *cur_node = NULL;
    xmlNode *body_child_node = NULL;

    doc = xmlReadFile(xml_GetProfiles_respon, NULL, 0);
    if (doc == NULL)
    {
        fprintf(stderr, "Failed to parse %s\n", xml_GetProfiles_respon);
    }
    root_element = xmlDocGetRootElement(doc);
    if (root_element == NULL)
    {
        return -1;
    }

    print_element_names(root_element);

    return 0;
}
